<!DOCTYPE HTML>
 <?php session_start();?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<title>期末设计</title>
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	
	<body>
		
		<?php
		  include'../public/header.php';
		?>

	<!-- 写日志 -->
		
		<section>

			<?php
	        //连接数据库
			$conn;
			include '../public/conn.php';
		
			if(!empty($_GET['id'])){
				$sql="select * from log where log_id = '".$_GET['id']."'";
				//die($sql);
				$query = mysql_query($sql);
				$rs = mysql_fetch_array($query);
				}

	            ?>
			<form action="upliad_flie.php"  method="post" enctype="multipart/form-data">

				<h1>Write article</h1>
				<input style="display:none;" name="log_id" value="<?php echo $_GET['id'];?>" />
				<input class="title" id="logTitle" type="text" name="logTitle" value="<?php echo $rs['log_title'] ?>"  
				 style=" height:30px">	
						
				<?php //die($rs['log_title']); ?>
				<textarea id="logContent" name="logContent" /><?php echo $rs['log_content'] ?> </textarea>
				<?php //die($rs['log_contents']); ?>

				 <select id="logUnit" name="logUnit">
                  <option value="0"> 开发 </option>
                  <option value="1"> 讨论 </option>
                </select>

                <select id="logUnit" name="logUnit">

                  <option value="0"> Module 1 </option>
                  <option value="1"> Module 2 </option>
                  <option value="2"> Module 3 </option>
                  <option value="3"> Module 4 </option>

                </select>
				<form action="upload_file.php">
				<input type="file" name="file" id="file"/>
				<input type="submit" name="submit" value="Submit" />
			</form>
		</section>
	<!-- 我的日志 -->	
		<aside>
			<h1>My article</h1>
			<ul>
				   <!--连接数据库-->
      			<?php
  				    $conn;
			        include '../public/conn.php';

				    // 检查是否已设置session
					$strName=$_SESSION['userName'];
				    $id=mysql_query("select sid from student where sna='$strName'", $conn);
				    $row=mysql_fetch_array($id);
				    $sID=$row['sid'];

					//读取数据
					$res=mysql_query("select  * from log where sid=$sID ");
					$rows=mysql_num_rows($res);
					$row = mysql_fetch_array($res);

                    //循环输出用户日志
					for($i=0; $i<$rows; $i++){

						$title = $row['log_title'];
						$log_date = $row['log_date'];
						$log_time = $row['log_time'];					
				?>
				<li>
				  <a href="../log/log_read.php?> id = <?php echo $row['log_id']?>">
				  <?php echo ($i+1).". ".$title."--------------".$log_date."--".$log_time; ?>
				  </a></li>

				  <li><a href="student_edit.php?id= <?php echo $row['log_id']?>">编辑</a>
				   |<a href="del.php?del= <?php echo $row['log_id']?>">删除</a></li>
			    
				<?php 
					$row = mysql_fetch_array($res);
				}?>
			</ul>
		</aside>
		
		<div id="dec"><img id="decimg" src="1.jpg"/></div>
		
		<div id="stu">
			<img id="stuimg" src="sinfor.jpg"/>
			
			<?php 
		
		      if(isset($_SESSION['userName'])) {
	            echo "<h3>Hello！<span>".$_SESSION['userName']."</span>同学</h3>";
		       }
		       else {
	             echo "<script>";
	             echo "alert('You are not logged, please login.');";
	             echo "location.href = '../reg_login/sign.html';";
	             echo "</script>";	
	           }
	         ?>
			<h5>Num of articles<span><?php echo $rows; ?></span></h5>
		</div>		
	</body>
</html>